import urllib3
import json

# 表单数据
form_data = {
    "page": 1,
    "limit": 5,
}
url = "http://www.layui.com/demo/table/user"
http_client = urllib3.PoolManager()
response = http_client.request(method='GET', url=url, fields=form_data)
if response.status == 200:
    reponse_text = response.data
    if len(reponse_text) > 0:
        dict = json.loads(reponse_text)
        for k, v in dict.items():
            print(k, '>>>', v)
        emps = dict['data']
        for emp in emps:
            print(emp)
        with open(file='layui.json', mode='w', encoding='utf-8') as f:
            f.write(response.data.decode('utf-8'))
